<template>
	<app-page>
		<wd-config-provider :theme="theme">
			<view class="container">
				<view class="result card">
					<wd-cell-group>
						<wd-cell title="医疗费（元）" :value="calculateResult.medicalExpenses" />
						<wd-cell title="误工费（元）" :value="calculateResult.lostCost" label="受害人月工资 / 30 * 误工天数" />
						<wd-cell title="护理费（元）" :value="calculateResult.nursingCost" label="护工年工资 / 365 * 护理天数" />
						<wd-cell title="营养费（元）" :value="calculateResult.nutritionCost" label="当地营养补助标准 * 营养期限" />
						<wd-cell title="住院伙食补助（元）" :value="calculateResult.hospitalCost" label="当地住院伙食补助标准 * 住院期限" />
						<wd-cell title="后续治疗费（元）" :value="calculateResult.subsequentTreatment" />
						<wd-cell title="交通费（元）" :value="calculateResult.transportationExpenses" />
						<wd-cell title="精神损害赔偿（元）" :value="calculateResult.spiritualCompensation" />
						<wd-cell title="残疾辅助器具费（元）" :value="calculateResult.disabledEquipment" />
						<wd-cell title="伤残赔偿（元）" :value="calculateResult.disabilityCompensation" />
						<wd-cell title="合计（元）" :value="all" />
						<!-- label="医疗费 + 误工费 + 护理费 + 营养费 + 住院伙食补助 + 后续治疗费 + 交通费 + 精神损害赔偿 + 残疾辅助器具费 + 伤残赔偿" -->
					</wd-cell-group>
				</view>
			</view>
		</wd-config-provider>
	</app-page>
</template>

<script lang="ts">
	import { defineComponent, ref, computed } from 'vue';

	import { onPageScroll, onLoad } from '@dcloudio/uni-app';



	export default defineComponent({
		name: '',
		components: {},
		setup(props, ctx) {
			// 日间light、夜间dark主题
			const theme = ref('light');
			const calculateResult : any = ref({});
			const all = computed(() => {
				let d = Number(calculateResult.value.medicalExpenses || 0);
				d += Number(calculateResult.value.lostCost || 0);
				d += Number(calculateResult.value.nursingCost || 0);
				d += Number(calculateResult.value.nutritionCost || 0);
				d += Number(calculateResult.value.hospitalCost || 0);
				d += Number(calculateResult.value.subsequentTreatment || 0);
				d += Number(calculateResult.value.transportationExpenses || 0);
				d += Number(calculateResult.value.spiritualCompensation || 0);
				d += Number(calculateResult.value.disabledEquipment || 0);
				d += Number(calculateResult.value.disabilityCompensation || 0);
				return d.toFixed(2); // 保留两位小数点
			})
			onLoad((params) => {
				calculateResult.value = params;
			});
			return {
				theme,
				all,
				calculateResult
			};
		}
	});
</script>
<!-- #ifdef MP-WEIXIN -->
<style lang="less">
	page {
		background-color: #f2f2f2;
	}
</style>
<!-- #endif -->
<style lang="less" scoped>
	.container {
		padding: 24rpx;
		background-color: #f2f2f2;

		.result {

			overflow: hidden;
		}
	}
</style>